//
//  ViewController.swift
//  JNLeetCode
//
//  Created by Renju Jiang on 2018/12/8.
//  Copyright © 2018 jiangrenju. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        

    }
    
    func stringLCode() {
        //字符串
        let string = LeetCodeString.init()
        _ = string.lengthOfLongestSubstring("abcaab")
        
        _ = string.longestCommonPrefix(strs: ["dog", "sfg", "alghalhgag"])
        
        _ = string.multipy("0", "0")
        
        _ = string.checkInclusion("adc", "dcda")

        _ = string.simplifyPath("/a/./b/../../c/")
        
        let ips = string.restoreIPAddresses("25525511135")
        print("ips:\(ips)")
        
        //Array
        let arr = LeetCodeArray()
        var nums = [-1, 0, 1, 2, -1, -4]
        
        arr.quickSort(nums: &nums, start: 0, end: nums.count-1)
        print(nums)

//        arr.threeSum([-1, 0, 1, 2, -1, -4])
        _ = arr.threeSum([1,2,-2,-1])
        
        let date1 = Date().timeIntervalSince1970
       
        _ = arr.threeSum(nums)
        let date2 = Date().timeIntervalSince1970
        print("time:\(date2 - date1)")
        
    }
    
    @IBAction func clickLeetCode(_ sender: Any) {
        stringLCode()
    }
    
}

